load("//tools/build_defs:glob_defs.bzl", "subdir_glob")
load("//tools/build_defs/android:fb_xplat_android_cxx_library.bzl", "fb_xplat_android_cxx_library")
load("//tools/build_defs/oss:profilo_defs.bzl", "profilo_path")

fb_xplat_android_cxx_library(
    name = "headers_linux",
    header_namespace = "profilo/perfevents/linux",
    exported_headers = subdir_glob([
        ("headers", "*.h"),
    ]),
    labels = [],
    visibility = ["PUBLIC"],
)

fb_xplat_android_cxx_library(
    name = "file_backed_mappings_list",
    header_namespace = "profilo/perfevents",
    exported_headers = [
        "detail/FileBackedMappingsList.h",
    ],
    labels = [],
    visibility = [
        profilo_path("..."),
    ],
    exported_deps = [
        profilo_path("deps/procmaps:procmaps"),
    ],
)

fb_xplat_android_cxx_library(
    name = "perfevents",
    srcs = [
        "Event.cpp",
        "Records.cpp",
        "Session.cpp",
        "detail/AttachmentStrategy.cpp",
        "detail/BufferParser.cpp",
        "detail/ClockOffsetMeasurement.cpp",
        "detail/RLimits.cpp",
        "detail/Reader.cpp",
        "jni.cpp",
    ],
    header_namespace = "profilo/perfevents",
    exported_headers = glob([
        "*.h",
        "detail/*.h",
    ]),
    allow_jni_merging = True,
    compiler_flags = [
        "-fexceptions",
        "-frtti",
        "-O3",
        "-std=gnu++14",
        "-DLOG_TAG=\"Profilo/perfevt\"",
    ],
    labels = [],
    soname = "libprofilo_perfevents.$(ext)",
    visibility = [
        profilo_path("..."),
        profilo_path("cpp/perfevents/..."),
    ],
    deps = [
        ":headers_linux",
        profilo_path("cpp:constants"),
        profilo_path("cpp:profilo"),
        profilo_path("cpp/jni:jmulti_buffer_logger"),
        profilo_path("cpp/util:util"),
        profilo_path("deps/fb:fb"),
        profilo_path("deps/fbjni:fbjni"),
        profilo_path("deps/procmaps:procmaps"),
    ],
)
